package org.zsl.lesson4_aop;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.zsl.lesson4_aop.service.ApplicationCf;
import org.zsl.lesson4_aop.service.hr.EmployeeService;
import org.zsl.lesson4_aop.service.hr.EmployeeServiceImpl2;
import org.zsl.lesson4_aop.service.proxy.IRent;
import org.zsl.lesson4_aop.service.proxy.RentProxy;
import org.zsl.lesson4_aop.service.proxy.Rentor;
import org.zsl.lesson4_aop.service.stock.StockService;
import org.zsl.lesson4_aop.service.stock.StockServiveImpl2;

public class AOPTestor {

    @Test
    public void testAop(){

        ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationCf.class);

        StockService stockServiveImpl2= (StockService) context.getBean("stockServiveImpl2");

        stockServiveImpl2.inStock();

        EmployeeService employeeService= (EmployeeService) context.getBean("employeeServiceImpl2");

        employeeService.newDocument();

    }

    @Test
    public void testProxy(){

        Rentor rentor1 = new Rentor();
        RentProxy proxy = new RentProxy(rentor1);

        IRent rent = proxy;

        rent.rent();


    }
}
